Libraries

library(tidyverse)
library(hrbrthemes)
library(kableExtra)

library(ggplot2)

library(plotly)
setwd("D:\\akb")

coba <- read.csv("infant.csv", sep = ";")

attach(coba)

head(coba)
##           Provinsi   IMR
## 1             Aceh 27.18
## 2   Sumatera Utara 31.54
## 3   Sumatera Barat 30.40
## 4             Riau 22.40
## 5            Jambi 23.77
## 6 Sumatera Selatan 28.48
p <- coba %>%
  filter(!is.na(IMR)) %>%
  arrange(as.ordered(IMR)) %>%
  mutate(Provinsi = factor(Provinsi, Provinsi)) %>%
  ggplot(aes(x = Provinsi, y = IMR)) +
  labs (title = "Angka Kematian Bayi" , x = " ", y = " ", subtitle = " Angka Kematian Bayi Per 1000 Kelahiran ",
        caption = "Source : Central Bureau Of Statistic (BPS) | Plot generated by : Antonito") +
  geom_bar(stat = "identity", fill = "brown") +
  coord_flip() +
  theme_ipsum()
p

ggplotly(p)
coba %>%
  filter(!is.na(IMR)) %>%
  arrange(IMR) %>%
  mutate(Provinsi=factor(Provinsi, Provinsi)) %>%
  ggplot(aes(x = Provinsi, y = IMR)) +
  labs(title = "Angka Kematian Bayi" , x = " ", y = "Kematian Per 1.000 Kelahiran Hidup ", subtitle = "Provinsi dengan Angka Kematian Bayi Tertinggi",
       caption = "Source : Central Bureau of Statistic (BPS), 2016 | Plot generated by : Antonito") +
  geom_bar(stat = "identity", fill = "brown") +
  coord_flip() +
  theme_ipsum() +
  theme(panel.grid.minor.y = element_blank(),
        panel.grid.major.y = element_blank(),
        legend.position = "none") 

tmpp <- coba %>%
  filter(!is.na(IMR)) %>%
  arrange(desc(IMR)) %>%
  mutate(Provinsi = factor(Provinsi, Provinsi))

tmpp
##                Provinsi   IMR
## 1        Sulawesi Barat 50.02
## 2                 Papua 45.74
## 3           Papua Barat 44.95
## 4                Maluku 44.65
## 5   Nusa Tenggara Barat 43.30
## 6   Nusa Tenggara Timur 40.48
## 7             Gorontalo 36.71
## 8          Maluku Utara 35.68
## 9     Kalimantan Tengah 34.84
## 10      Sulawesi Tengah 34.76
## 11   Kalimantan Selatan 33.72
## 12       Sumatera Utara 31.54
## 13       Sumatera Barat 30.40
## 14             Bengkulu 30.10
## 15     Sumatera Selatan 28.48
## 16               Banten 27.85
## 17                 Aceh 27.18
## 18            Kep. Riau 26.81
## 19     Sulawesi Selatan 26.46
## 20     Kalimantan Barat 25.85
## 21              Lampung 25.66
## 22            Indonesia 25.50
## 23 Kep. Bangka Belitung 25.45
## 24    Sulawesi Tenggara 24.77
## 25                Jambi 23.77
## 26           Jawa Timur 23.58
## 27       Sulawesi Utara 22.47
## 28                 Riau 22.40
## 29          Jawa Tengah 22.07
## 30                 Bali 20.93
## 31           Jawa Barat 18.08
## 32          Dki Jakarta 17.76
## 33     Kalimantan Timur 14.71
## 34        Di Yogyakarta 12.52
kematian = read.csv("bayi.csv", sep = ";")


p2 <- kematian %>%
  filter(!is.na(AKB)) %>%
  arrange(as.ordered(AKB)) %>%
  mutate(Wilayah = factor(Wilayah, Wilayah)) %>%
  ggplot(aes(x = Wilayah, y = AKB)) +
  labs (title = "Angka Kematian Bayi Jawa Timur" , x = " ", y = "Kematian Per 1.000 Kelahiran Hidup ", subtitle = " Angka Kematian Bayi Per 1000 Kelahiran ",
        caption = "Source : Central Bureau Of Statistic East Java (BPS) | Plot generated by : Antonito") +
  geom_bar(stat = "identity", fill = "tomato4") +
  coord_flip() +
  theme_ipsum()
p2

ggplotly(p2)
k = kematian %>%
  filter(!is.na(AKB)) %>%
  arrange(AKB) %>%
  mutate(Wilayah=factor(Wilayah, Wilayah)) %>%
  ggplot(aes(x = Wilayah, y = AKB)) +
  labs(title = "Angka Kematian Bayi" , x = " ", y = "Kematian Per 1.000 Kelahiran Hidup ", subtitle = "Kabupaten/Kota dengan Angka Kematian Bayi Tertinggi di Jatim",
       caption = "Source : Central Bureau of Statistic (BPS) East Java, 2016 | Plot generated by : Antonito") +
  geom_bar(stat = "identity", fill = "steelblue4") +
  coord_flip() +
  theme_ipsum() +
  theme(panel.grid.minor.y = element_blank(),
        panel.grid.major.y = element_blank(),
        legend.position = "none") 

k

ggplotly(k)